package com.hzlj.position.config.converter;

import com.hzlj.position.config.common.dto.operatorActivation.OperatorActivationAddDTO;
import com.hzlj.position.config.common.dto.operatorActivation.OperatorActivationQueryResultDTO;
import com.hzlj.position.config.common.dto.operatorActivation.OperatorActivationDTO;
import com.hzlj.position.config.common.model.OperatorActivation;
import com.fz.common.base.converter.ModelDTOConverter;
import com.fz.common.base.core.date.DateUtils;

/**
 * 定位-运营商开通(OperatorActivation)DTO转换类
 *
 * @author lifh
 * @date 2023-08-10 17:30:17
 */
public class OperatorActivationConverter {
    /**
     * model实例转换为查询结果DTO
     *
     * @param model model实例
     * @return DTO
     */
    public static OperatorActivationQueryResultDTO from(OperatorActivation model) {
        return ModelDTOConverter.from(model, OperatorActivationQueryResultDTO.class);
    }

    /**
     * 新增DTO转换为model实例
     *
     * @param dto 新增DTO
     * @return model实例
     */
    public static OperatorActivation from(OperatorActivationAddDTO dto) {
        return ModelDTOConverter.from(dto, OperatorActivation.class, (OperatorActivation l) -> {
            l.setValid(true);
            l.setUpdateTime(DateUtils.now());
            l.setCreateTime(DateUtils.now());
        });

    }

    /**
     * 修改DTO转换为model实例
     *
     * @param dto 修改DTO
     * @return model实例
     */
    public static OperatorActivation from(OperatorActivationDTO dto) {
        return ModelDTOConverter.from(dto, OperatorActivation.class, (OperatorActivation l) -> {
            l.setUpdateTime(DateUtils.now());
        });
    }
}
